﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FinosLibrary;
using System.Data.Linq;
using System.Collections;
using System.ComponentModel;
using System.Reflection;
using System.Reflection.Emit;
namespace BattleShip {
    [MessageProcess(MPType.PropClient, appName = "BattleShip")]
    public class PCTable : ModelLogic {
        [AutoWire]
        public DataClassesDataContext database;
        public ITable Table { 
            get {
                //return _Table.GetType().GetMethod("Skip").Skip(PageSelection * Static.PageSize).Take(Static.PageSize);
                return database.GetTable(Type.GetType("BattleShip." + tableName));
            }
        }
        private string _tableName;
        public string tableName {
            get { return _tableName; }
            set {
                _tableName = value;
                this.NotifyPropertyChanged(x => x.TablePage);
                PageSelection = 0;
            }
        }
        public int[] TablePage {
            get {
                var array = new int[100/ Static.PageSize + 1];
                for (var i = 0; i < array.Length; i++) array[i] = i;
                return array;
            }
        }
        private int _PageSelection;
        public int PageSelection {
            get { return _PageSelection; }
            set {
                _PageSelection = value;
                this.NotifyPropertyChanged(x => x.PageSelection);
                this.NotifyPropertyChanged(x => x.Table);
            }
        }
    }
}
